package com.orhonit.ipb.portal.biz;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.orhonit.ipb.portal.entity.TbPartyOrgBaseInfo;
import com.orhonit.ipb.portal.mapper.TbPartyOrgBaseInfoMapper;
import com.orhonit.ipb.portal.mapper.TbPartyOrgCatalogMapper;
import com.orhonit.ipb.security.common.biz.BaseBiz;


/**
 * 党组织基本信息表
 *
 * @author caodw
 * @email caodw@qq.com
 * @version 2018-04-23 11:23:42
 */
@Service
public class TbPartyOrgBaseInfoBiz extends BaseBiz<TbPartyOrgBaseInfoMapper,TbPartyOrgBaseInfo> {
	@Autowired
	private TbPartyOrgBaseInfoMapper tbPartyOrgBaseInfoMapper;
	@Autowired
	private TbPartyOrgCatalogMapper tbPartyOrgCatalogMapper;
	/**
	 * 通过组织代码查找组织类别
	 * @param pOrganizationCode
	 * @return
	 */
	public TbPartyOrgBaseInfo getTbPartyOrgBaseInfoBypOrganizationCode(String pOrganizationCode){
		TbPartyOrgBaseInfo temp= tbPartyOrgBaseInfoMapper.getTbPartyOrgBaseInfoBypOrganizationCode(pOrganizationCode);
		if(!temp.getPOrganizationType().equals("1")){
			String deptid=tbPartyOrgCatalogMapper.getTbPartyOrgCatalogByDeptId(temp.getPOrganizationCode());
			TbPartyOrgBaseInfo temp2=tbPartyOrgBaseInfoMapper.getTbPartyOrgBaseInfoBypOrganizationCode(deptid);
			return this.getTbPartyOrgBaseInfoBypOrganizationCode(temp2.getPOrganizationCode());
		}
		else{
			return temp;
		}
		
	}
}